<?php
class chat extends CI_Controller{

var $port = 80;
var $domain = 'http://mynode-rdmordido.dotcloud.com';
var $analyticsAccount = '';
var $analyticsDomainName = '';

	public function __construct(){
		parent::__construct();
	}
	
	
	public function index(){
		
		
		$data['config'] = array(
					'subtwich'	=>	$this->input->server('HTTP_HOST'),
					'room'		=>	$this->input->get('room'),
					'host'		=>	$this->input->server('SERVER_NAME'),
					'port'		=>	$this->port,
					'protocol'	=>	'http://',
					'node_url'	=>	$this->domain.':'.$this->port,
					'autouser'	=>	(strstr($this->input->server('QUERY_STRING'), '&autouser')) ? str_replace(" ", "_", $this->input->get('autouser')) :""
		);
		if (strstr($this->input->server('QUERY_STRING'), '&logout')) {
        	redirect('Location: http://' . $this->input->server('SERVER_NAME') . '/' . $this->input->get('room'));
    	}
		else{
			$this->load->view('chat',$data);
		}
	}
	
	public function subtwich($_s) {
	    $host_arr = explode(".",$_s);
	    array_pop($host_arr);
	    array_pop($host_arr);
	    return implode('.',$host_arr);
	}
}
	